home *** CD-ROM | disk | FTP | other *** search
- #!NETQUOTEVAR:PERLPATH
- #######################################################
- # #
- # The above is the Path to Perl on the ISP's server #
- # #
- # Requires Perl version 5.0 or later #
- # Requires Perl MD5 module #
- # #
- #######################################################
-
-
- #######################################################
- # #
- # PROBLEM SOLVING #
- # #
- # Listed below are the most common reasons why this #
- # script may fail to operate correctly: #
- # #
- # This cgi script MUST be installed in the 'CGI-BIN' #
- # directory allocated to the user on server of the #
- # Internet Service Provider. #
- # #
- # The script MUST be uploaded to this directory as #
- # an ASCII file. Do NOT use the 'AUTO' option in your #
- # FTP program for the type of file upload . We have #
- # found that some of these FTP programs default to an #
- # incorrect upload format. #
- # #
- # If you receive any error messages from the server, #
- # usually with an error code of 500 or 501, then the #
- # cause will usually be that this file has been sent #
- # to the server using the wrong transfer mode. To #
- # this please re-upload this file as an ASCII file. #
- # #
- # The file permissions need to be correctly set on #
- # this file when it is installed on UNIX servers. #
- # These permissions need to be set as 'rwx r-x r-x' #
- # which equates to a file mask of '755'. These can #
- # usually be easily set via your FTP program. #
- # #
- # Perl MD5 module must be installed at the ISP site #
- # and must be accessible by this script. #
- # #
- #######################################################
-
- #?use CGI::Carp qw(fatalsToBrowser);
-
- #
- # Make sure "." is included in the @INC directory list so we can find our packages
- #
- my $bFound = 0;
- my $sDir;
- foreach $sDir (@INC)
- {
- if ($sDir eq ".")
- {
- $bFound = 1;
- last;
- }
- }
- if (!$bFound)
- {
- push (@INC, ".");
- }
- #
- # NT systems rarely execute the CGI scripts in the cgi-bin, so attempt to locate
- # the packages in that case. This may still fail if the cgi-bin folder is named
- # something else, but at least we will catch 80% of the cases. The INCLUDEPATHADJUSMENT
- # covers the remaining cases.
- #
- push (@INC, "cgi-bin");
- NETQUOTEVAR:INCLUDEPATHADJUSTMENT
-
- require NETQUOTEVAR:ACTINICPACKAGE;
- require NETQUOTEVAR:ACTINICSAFER;
- require NETQUOTEVAR:ACTINICDIFFIE;
- require NETQUOTEVAR:ACTINICENCRYPT;
- require NETQUOTEVAR:ACTINICORDER;
- use strict;
-
- #######################################################
- # #
- # CATALOG CUSTOMER ACCOUNTS CGI/PERL SCRIPT #
- # #
- # Copyright (c) 1999 ACTINIC SOFTWARE LIMITED #
- # #
- # written by Richard Zybert #
- # #
- #######################################################
-
- $::prog_name = "CATACACC"; # Program Name (8 characters)
- $::prog_ver = '$Revision: 16 $'; # program version (6 characters)'
- $::prog_ver = substr($::prog_ver, 11); # strip the revision information
- $::prog_ver =~ s/ \$//; # and the trailers
-
- Init();
- CAccDispatch();
- exit;
-
- sub CAccDispatch
- {
- if( $::g_InputHash{ACTION} eq 'LOGOUT' )
- {
- CaccLogout();
- }
- ACTINIC::CAccLogin();
- if( $::g_InputHash{PRODUCTPAGE} =~ /\S/ )
- {
- $ACTINIC::B2B->Set('ProductPage',$::g_InputHash{PRODUCTPAGE});
- }
- if( $ACTINIC::B2B->Get('ProductPage') )
- {
- $ACTINIC::B2B->Set('ProductFileCookie',ACTINIC::EncodeText2($ACTINIC::B2B->Get('ProductPage'), $::FALSE));
- }
- CAccPrintPage();
- }
- sub CaccLogout
- {
- my $sHTML;
- my ($sAccountCookie,$sBaseFile) = ACTINIC::CaccGetCookies();
- $sHTML = "<HTML><HEAD><META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=".$sBaseFile."\"><BODY></BODY></HTML>";
- $ACTINIC::B2B->Set('UserIDCookie',".");;
- CAccPrintPageWithOptionalHighlight($sHTML, undef, $::FALSE);
- exit;
- }
-
- #######################################################
- #
- # CAccPrintPage - Print the HTML to the browser.
- #
- # Params: [0] - HTML
- #
- #######################################################
-
- sub CAccPrintPage
- {
- my $sHTML = shift;
- if( $sHTML )
- {
- CAccPrintPageWithOptionalHighlight($sHTML, undef, $::FALSE);
- exit;
- }
- #
- # Build the HTML, print and exit - don't return
- #
- my ($sProductPage,$sBodyPage);
- if( $::g_InputHash{PRODUCTPAGE} =~ /\S/ )
- {
- $sProductPage = $::g_InputHash{PRODUCTPAGE};
- }
- else
- {
- ($sBodyPage,$sProductPage) = ACTINIC::CAccCatalogBody();
- }
- if( $::g_InputHash{MAINFRAMEURL} =~ /\S/ )
- {
- $sBodyPage = $::g_InputHash{MAINFRAMEURL};
- }
-
- my ($sFirst,$sLast) = split("#",$sProductPage); # isolate anchors
-
- my @Response = ACTINIC::TemplateFile(ACTINIC::GetPath() . $sFirst); # make the substitutions
- if ($Response[0] != $::SUCCESS)
- {
- return (@Response);
- }
- #
- # clean up the links
- #
- my $sPath = $ACTINIC::B2B->Get('BaseFile');
- if( $sLast ) { $sPath .= "#$sLast" } # insert anchor back
- my $sCgiUrl = $::g_sAccountScript;
- $sCgiUrl .= ($::g_InputHash{SHOP} ? '?SHOP=' . ACTINIC::EncodeText2($::g_InputHash{SHOP}, $::FALSE) . '&' : '?');
- $sCgiUrl .= "ACTINIC_REFERRER=" . ACTINIC::EncodeText2($::g_sAccountScript) . '&';
- if( $sBodyPage and $sBodyPage ne $sProductPage )
- {
- $sCgiUrl .= "MAINFRAMEURL=$sBodyPage" . '&PRODUCTPAGE=';
- }
- else
- {
- $sCgiUrl .= "PRODUCTPAGE=";
- }
-
- @Response = ACTINIC::MakeLinksAbsolute($Response[2], $sCgiUrl, $sPath);
- if ($Response[0] != $::SUCCESS)
- {
- return (@Response);
- }
- $sHTML = $Response[2];
- #
- # Now do the XML tags and print
- #
- CAccPrintPageWithOptionalHighlight($sHTML, undef, $::FALSE);
- exit;
- }
-
- #######################################################
- #
- # CAccPrintPageWithOptionalHighlight - print the page
- # If the search script arguments are in place, do
- # the search script highlighting before print.
- #
- # Input: 0 - HTML to print
- # 1 - cookie
- # 2 - HTTP header cache status
- # ($::TRUE = no cache)
- #
- # Expects: %::g_InputHash to contain the CGI params
- # $::g_pSearchSetup blob with search config
- # hash
- #
- #######################################################
-
- sub CAccPrintPageWithOptionalHighlight
- {
- #? ACTINIC::ASSERT($#_ == 2, "Incorrect parameter count CAccPrintPageWithOptionalHighlight(" . join(', ', @_) . ").", __LINE__, __FILE__);
- my ($sHTML, $sCookie, $bNoCache) = @_;
- #
- # See if we are to highlight anything
- #
- my $sWords = $::g_InputHash{WD}; # retrieve the words to highlight
- if ($sWords)
- {
- ACTINIC::HighlightWords($sWords, $$::g_pSearchSetup{SEARCH_HIGHLIGHT_START}, $$::g_pSearchSetup{SEARCH_HIGHLIGHT_END}, \$sHTML);
- }
-
- ACTINIC::PrintPage($sHTML, $sCookie, $bNoCache);
- }
-
- #######################################################
- #
- # Init - initialize the script
- #
- #######################################################
-
- sub Init
- {
- $::g_bFirstError = $::TRUE; # this flag indicates that the display page method has entered recursion
- # due to errors - it prevents infinite recursion
- my (@Response, $Status, $Message);
-
- @Response = ReadAndParseInput(); # read the input from the CGI call
- ($Status, $Message) = @Response; # parse the response
- if ($Status != $::SUCCESS)
- {
- ACTINIC::ReportError($Message, ACTINIC::GetPath());
- }
-
- @Response = ReadAndParseBlobs(); # read the catalog blobs
- ($Status, $Message) = @Response; # parse the response
- if ($Status != $::SUCCESS)
- {
- ACTINIC::ReportError($Message, ACTINIC::GetPath());
- }
- }
-
- #######################################################
- #
- # ReadAndParseInput - read the input and parse it
- #
- # Expects: $ENV to be defined
- #
- # Affects: @::g_PageList - global list of pages visited
- #
- # Returns: ($ReturnCode, $Error)
- # if $ReturnCode = $FAILURE, the operation failed
- # for the reason specified in $Error
- # Otherwise everything is OK
- #
- #######################################################
-
- sub ReadAndParseInput
- {
- my ($status, $message, $temp);
- ($status, $message, $::g_OriginalInputData, $temp, %::g_InputHash) = ACTINIC::ReadAndParseInput();
- if ($status != $::SUCCESS)
- {
- return ($status, $message, 0, 0);
- }
- #
- # parse the ref page list
- #
- ($status, $message, @::g_PageList) = ACTINIC::ProcessReferencePageData(%::g_InputHash);
- if ($status != $::SUCCESS)
- {
- return ($status, $message, 0, 0);
- }
-
- #######
- # retrieve the web site url
- #######
- ($status, $message, $::g_sWebSiteUrl, $::g_sContentUrl) = ACTINIC::GetWebSiteURL(@::g_PageList);
- if ($status != $::SUCCESS)
- {
- return ($status, $message, 0, 0);
- }
-
- return ($::SUCCESS, "", 0, 0);
- }
-
-
- #######################################################
- #
- # ReadAndParseBlobs - read the blobs and store them
- # in global data structures
- #
- # Expects: %::g_InputHash - the input hash table should
- # be defined
- #
- # Affects: $g_sCartId - the cart ID for this customer
- # %g_BillContact - the invoice contact information
- # %g_ShipContact - the delivery contact information
- # %g_ShipInfo - the shipping information
- # %g_TaxInfo - the tax information
- # %g_GeneralInfo - general information
- # %g_PaymentInfo - payment information
- #
- # Returns: ($ReturnCode, $Error)
- # if $ReturnCode = $FAILURE, the operation failed
- # for the reason specified in $Error
- # Otherwise everything is OK
- #
- #######################################################
-
- sub ReadAndParseBlobs
- {
- my ($Status, $Message, @Response, $sPath);
-
- $sPath = ACTINIC::GetPath(); # get the path to the web site
-
- @Response = ACTINIC::ReadCatalogFile($sPath); # read the catalog blob
- ($Status, $Message) = @Response; # parse the response
- if ($Status != $::SUCCESS) # on error, bail
- {
- return (@Response);
- }
-
- @Response = ACTINIC::ReadSetupFile($sPath); # read the setup
- ($Status, $Message) = @Response;
- if ($Status != $::SUCCESS)
- {
- return (@Response);
- }
-
- @Response = ACTINIC::ReadLocationsFile($sPath); # read the locations
- ($Status, $Message) = @Response;
- if ($Status != $::SUCCESS)
- {
- return (@Response);
- }
- #
- # read the phase blob
- #
- @Response = ACTINIC::ReadPhaseFile($sPath);
- if ($Response[0] != $::SUCCESS)
- {
- return (@Response);
- }
- #
- # read the prompt blob
- #
- @Response = ACTINIC::ReadPromptFile($sPath);
- if ($Response[0] != $::SUCCESS)
- {
- return (@Response);
- }
- #
- # read the tax blob
- #
- @Response = ACTINIC::ReadTaxSetupFile($sPath);
- if ($Response[0] != $::SUCCESS)
- {
- return (@Response);
- }
- #
- # read the tax blob
- #
- @Response = ACTINIC::ReadSearchSetupFile($sPath);
- if ($Response[0] != $::SUCCESS)
- {
- return (@Response);
- }
- #
- # read the cart ID
- #
- @Response = ActinicOrder::GetCartID(ACTINIC::GetPath()); # retrieve the cart ID
- ($Status, $Message, $::g_sCartId) = @Response;
- if ($Status != $::SUCCESS) # error out
- {
- return (@Response);
- }
-
- #
- # read the checkout status
- #
- my ($pBillContact, $pShipContact, $pShipInfo, $pTaxInfo, $pGeneralInfo, $pPaymentInfo, $pLocationInfo);
- @Response = ActinicOrder::RetrieveCheckoutStatus($sPath, $::g_sCartId);
- if ($Response[0] != $::SUCCESS)
- {
- return (@Response);
- }
- ($Status, $Message, $pBillContact, $pShipContact, $pShipInfo, $pTaxInfo, $pGeneralInfo, $pPaymentInfo, $pLocationInfo) = @Response;
- %::g_BillContact = %$pBillContact; # copy the hashes to global tables
- %::g_ShipContact = %$pShipContact;
- %::g_ShipInfo = %$pShipInfo;
- %::g_TaxInfo = %$pTaxInfo;
- %::g_GeneralInfo = %$pGeneralInfo;
- %::g_PaymentInfo = %$pPaymentInfo;
- %::g_LocationInfo = %$pLocationInfo;
-
- return ($::SUCCESS, "", 0, 0);
- }
-
-